<!-- 故障报修记录 详情 -->
<template>
	<uni-list :border="false">
		<uni-list-item title="工单号" :note="detailsData.gzdh" :rightText="zfdmFormatter('listSQZT', detailsData.gzdzt)" />
	</uni-list>
	<uni-section title="用户信息" type="line">
		<uni-list :border="false">
			<uni-list-item title="用户编号" :rightText="detailsData.yhbh" />
			<uni-list-item title="用户名称" :rightText="detailsData.yhmc" />
			<uni-list-item title="联系方式" :rightText="detailsData.yhdh" />
			<uni-list-item title="用户地址" :rightText="detailsData.yhdz" />
		</uni-list>
	</uni-section>
	<uni-section title="报修信息" type="line">
		<uni-list :border="false">
			<uni-list-item title="诉求时间" :rightText="detailsData.sqsj" />
			<uni-list-item title="诉求类型" :rightText="zfdmFormatter('listSQLX', detailsData.sqlx)" />
			<uni-list-item title="诉求内容" :rightText="detailsData.bxnr" />
		</uni-list>
	</uni-section>
	<uni-section title="处理信息" type="line">
		<uni-list :border="false">
			<uni-list-item title="处理时间" :rightText="detailsData.cljssj" />
			<uni-list-item title="处理方案" :rightText="detailsData.bxclfa" />
			<uni-list-item title="处理结果" :rightText="detailsData.cljg" />
		</uni-list>
	</uni-section>
	<uni-section title="处理信息" type="line">
		<uni-steps :options="[{
					title: '买家下单',
					desc: '2018-11-11'
				}, {
					title: '卖家发货',
					desc: '2018-11-12'
				}, {
					title: '买家签收',
					desc: '2018-11-13'
				}, {
					title: '交易完成',
					desc: '2018-11-14'
				}]" active-color="green" :active="1" direction="column" />
	</uni-section>

</template>

<script setup lang="ts">
	import { getZfdmByDmzl } from "@/api/request/getZfdmByDmzl";
	import { ref, reactive, onBeforeMount } from 'vue';
	import { onLoad } from '@dcloudio/uni-app'

	let detailsData = ref({})
	let state = reactive({
		details: {},
		listSQZT: [],
		listSQLX: []
	});
	onLoad((option) => {
		let data = option.detailsData || ''
		detailsData.value = JSON.parse(data)
	});


	onBeforeMount(() => {
		getListSQLX()
		getListSQZT()
	})
	function getListSQLX() {
		getZfdmByDmzl({
			data: {
				dmzl: "SQLX"
			},
			success: (res) => {
				let list = res || []
				state.listSQLX = list
			},
			fail: (code, message) => {
				console.log(code, message)
			}
		})
	}
	function getListSQZT() {
		getZfdmByDmzl({
			data: {
				dmzl: "SQZT"
			},
			success: (res) => {
				let list = res || []
				state.listSQZT = list
			},
			fail: (code, message) => {
				console.log(code, message)
			}
		})
	}
	function zfdmFormatter(key, value) {
		let zfdmArr = state[key].filter(item => item.dmbh == value);
		if (zfdmArr.length) {
			return zfdmArr[0].dmnr.split("-")[1];
		}
		return '';
	}
</script>

<style lang="scss" scoped>
</style>